package com.jdy.haoduoaiteacher.util;

import android.content.Context;
import android.widget.Toast;

import com.jdy.haoduoaiteacher.MyTeacherApp;

/**
 * 
 * @author Hufei
 * 
 */
public class AlertMessage {

  private static Toast toast;

  public static void show(Context context, String message, boolean isLong) {
    if (Tools.isEmpty(message)) {
      return;
    }
    int type = isLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
    showDefault(context, message, type);
  }

  @SuppressWarnings("static-access")
  private static void showDefault(Context context, String message, int duration) {
    if (toast == null) {
      toast = Toast.makeText(MyTeacherApp.getInstance().getAppContext(),
          message, duration);
    }
    toast.setDuration(duration);
    toast.setText(message);
    toast.show();

  }

  public static void show(Context context, String message) {
    show(context, message, false);
  }
}
